package com.android.delivery.base;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import com.android.delivery.App;
import com.blankj.utilcode.util.LogUtils;
import com.android.delivery.MainActivity;

/**
 * description: activity的生命周期回调 4.0+才有
 */
final class BaseActivityLifecycleCallback implements Application.ActivityLifecycleCallbacks{
	private static final String TAG = "ActivityLifecycle";

	@Override
	public void onActivityCreated(Activity activity, Bundle bundle) {
		LogUtils.v(TAG, activity.toString());
		if (activity instanceof BaseActivity){
			if (!(activity instanceof MainActivity)){
				App.Companion.getInstance().addActivity((BaseActivity) activity);

			}
		}
	}

	@Override
	public void onActivityStarted(Activity activity) {
//		LogUtils.v(TAG, activity.toString());
	}

	@Override
	public void onActivityResumed(Activity activity) {
//		LogUtils.v(TAG, activity.toString());
	}

	@Override
	public void onActivityPaused(Activity activity) {
//		LogUtils.v(TAG, activity.toString());
	}

	@Override
	public void onActivityStopped(Activity activity) {
//		LogUtils.v(TAG, activity.toString());
	}

	@Override
	public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
//		LogUtils.v(TAG, activity.toString());
	}

	@Override
	public void onActivityDestroyed(Activity activity) {
		LogUtils.v(TAG, activity.toString());
		if (activity instanceof BaseActivity){
			App.Companion.getInstance().removeActivity((BaseActivity) activity);
		}
	}
}
